home *** CD-ROM | disk | FTP | other *** search
- '/******************************************************************/
- '/* */
- '/* TurboCAD for Windows */
- '/* Copyright (c) 1993 - 2004 */
- '/* International Microcomputer Software, Inc. */
- '/* (IMSI) */
- '/* All rights reserved. */
- '/* */
- '/******************************************************************/
-
- Public Class VBNetTCTool
- Const NUM_TOOLS = 1
- Const boolLoadFromBmp = False
- Public Function Description() As String
- Description = "TurboCAD VB NET Tool"
- End Function
- Public Function Run(ByVal Tool As Object) As Boolean
- ' add your code here
- MsgBox("Add your code here !!!")
- End Function
-
- Public Function GetToolInfo(ByRef CommandNames As Object, ByRef MenuCaptions As Object, ByRef StatusPrompts As Object, _
- ByRef ToolTips As Object, ByRef Enabled As Object, ByRef WantsUpdates As Object) As Integer
- Dim StrCommandNames() As String
- Dim StrMenuCaptions(,) As String
- Dim StrStatusPrompts() As String
- Dim StrToolTips() As String
-
- Dim BoolEnabled() As Boolean
- Dim BoolWantsUpdates() As Boolean
-
- ReDim StrCommandNames(NUM_TOOLS - 1)
- ReDim StrMenuCaptions(NUM_TOOLS - 1, 1)
- ReDim StrStatusPrompts(NUM_TOOLS - 1)
- ReDim StrToolTips(NUM_TOOLS - 1)
- ReDim BoolEnabled(NUM_TOOLS - 1)
- ReDim BoolWantsUpdates(NUM_TOOLS - 1)
-
- StrCommandNames(0) = "Bonus Tools|VB NET tools|&TC VB NET Test Tool"
-
- StrMenuCaptions(0, 0) = "&TC VB NET Test Tool"
- ' toolbar's name
- StrMenuCaptions(0, 1) = "VB NET SDK samples"
-
- StrStatusPrompts(0) = "TC VB NET tool status prompt"
- StrToolTips(0) = "TC VB Net Tool tooltips"
-
- BoolEnabled(0) = True
- BoolWantsUpdates(0) = False
-
-
- MenuCaptions = StrMenuCaptions
- CommandNames = StrCommandNames
- StatusPrompts = StrStatusPrompts
- ToolTips = StrToolTips
- Enabled = BoolEnabled
- WantsUpdates = BoolWantsUpdates
- GetToolInfo = NUM_TOOLS
- End Function
- Public Function GetPicture(ByVal LargeImage As Boolean, ByVal MonoImage As Boolean) As Object
- On Error GoTo PictureError
- Dim TheImage As System.Drawing.Bitmap
- If GetButtonPicture(LargeImage, MonoImage, TheImage) Then
- Dim imConv As New ImageConverter("59EE46BA-677D-4d20-BF10-8D8067CB8B33")
- ' now we have bitmap. we need to convert it to IPicture
- GetPicture = imConv.ImageToIPicDisp(TheImage)
- End If
- Exit Function
- PictureError:
- MsgBox("GetPicture method failed " & Err.Description)
- GetPicture = Nothing
- End Function
- Public Function Initialize(ByVal Tool As Object) As Boolean
- Initialize = True
- End Function
- Public Function UpdateToolStatus(ByVal Tool As Object, ByVal Enabled As Boolean, ByVal Checked As Boolean) As Boolean
- Enabled = True 'Could do a test here to determine whether to disable the button/menu item
- Checked = False 'Could do a test here to determine whether to check the button/menu item
- UpdateToolStatus = True
- End Function
- Private Function GetButtonPicture(ByVal LargeImage As Boolean, ByVal MonoImage As Boolean, ByRef TheImage As Object) As Boolean
- On Error GoTo LoadError
- Dim s As String, s1 As String
- 'define correct path to the icons here'
- s = "C:\\temp\\LargeIcon.bmp"
- s1 = "C:\\Temp\\SmallIcon.bmp"
- ' copy of these bmp files are located in TCVBNETTool directory
- 'There are two ways to load images: from .Bmp file(s) or from .RES resource.
- 'In this demo, we control the loading by a private variable.
- Dim img As System.Drawing.Image
- Dim thisApp As System.Reflection.Assembly
- Dim file As System.IO.Stream
-
- If boolLoadFromBmp Then
- If LargeImage Then
- img = System.Drawing.Image.FromFile(s1) '"LargeIcon.bmp")
- Else
- img = System.Drawing.Image.FromFile(s) '"SmallIcon.bmp")
- End If
- Else
- If LargeImage Then
- thisApp = System.Reflection.Assembly.GetExecutingAssembly()
- file = thisApp.GetManifestResourceStream("TCVBNETTool.LargeIcon.bmp")
- img = System.Drawing.Image.FromStream(file)
- Else
- thisApp = System.Reflection.Assembly.GetExecutingAssembly()
- file = thisApp.GetManifestResourceStream("TCVBNETTool.SmallIcon.bmp")
- img = System.Drawing.Image.FromStream(file)
- End If
-
- End If
- ' return bitmap
- TheImage = img
- GetButtonPicture = True
- Exit Function
-
-
-
- LoadError:
- GetButtonPicture = False
- End Function
- Public Function CopyBitmap(ByVal LargeImage As Boolean, ByVal MonoImage As Boolean) As Boolean
-
- On Error GoTo BitmapError
- Dim TheImage As System.Drawing.Bitmap
- If GetButtonPicture(LargeImage, MonoImage, TheImage) Then
- 'Put the image on the Windows clipboard
- ' Dim datobj As New System.Windows.Forms.DataObject
- ' datobj = New System.Windows.Forms.DataObject(System.Windows.Forms.DataFormats.Dib, TheImage)
- System.Windows.Forms.Clipboard.SetDataObject(TheImage, True)
- CopyBitmap = True
- Exit Function
- End If
- Exit Function
- CopyBitmap = True
- Exit Function
-
- BitmapError:
- MsgBox("CopyBitmap method failed " & Err.Description)
- CopyBitmap = False
- End Function
- Private Class ImageConverter
- Inherits System.Windows.Forms.AxHost
-
- Public Sub New(ByVal pGUID As String)
- MyBase.New(pGUID)
- End Sub
-
- Public Shared Function ImageToIPicDisp(ByVal value As System.Drawing.Image) As stdole.IPictureDisp
- Return System.Windows.Forms.AxHost.GetIPictureDispFromPicture(value)
- End Function
-
- Public Shared Function IPicDispToImage(ByVal value As stdole.IPictureDisp) As System.Drawing.Image
- Return System.Windows.Forms.AxHost.GetPictureFromIPictureDisp(CType(value, Object))
- End Function
- End Class
-
-
- End Class
-